package tr.com.netgis;

import tr.com.netgis.util.Utility;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * GPS provider change
 * 
 * @author NetGis
 * 
 */
public class ProviderChangedBroadcastReceiver extends BroadcastReceiver {

	/**
	 * for action <b>android.location.PROVIDERS_CHANGED</b>
	 */
	private Runnable changedCallback;
	private Context context;
	
	/**
	 * 
	 * @param changedCallback for action <b>android.location.PROVIDERS_CHANGED</b>
	 */
	public ProviderChangedBroadcastReceiver(Context context, Runnable changedCallback) {
		super();
		this.context = context;
		this.changedCallback = changedCallback;
	}

	public Context getContext() {
		return this.context;
	}
	
	@Override
	public void onReceive(Context context, Intent intent) {
		String mAction = intent.getAction();
		if (mAction.equals("android.location.PROVIDERS_CHANGED")) {
			if (changedCallback != null) {
				changedCallback.run();
			}
		}
	}
	
	public boolean isGPSEnabled (){
		return Utility.isGPSEnabled(getContext());
	}

}
